package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.JobDayExamineAccount;
import com.ruoyi.system.mapper.JobDayExamineAccountMapper;
import com.ruoyi.system.service.JobDayExamineAccountService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 日审核表台账(JobDayExamineAccount)表服务实现类
 *
 * @author makejava
 * @since 2022-11-23 09:20:08
 */
@Service("jobDayExamineAccountService")
public class JobDayExamineAccountServiceImpl implements JobDayExamineAccountService {
    @Resource
    private JobDayExamineAccountMapper jobDayExamineAccountDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public JobDayExamineAccount queryById(Integer id) {
        return this.jobDayExamineAccountDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param jobDayExamineAccount 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<JobDayExamineAccount> queryByPage(JobDayExamineAccount jobDayExamineAccount, PageRequest pageRequest) {
        long total = this.jobDayExamineAccountDao.count(jobDayExamineAccount);
        return new PageImpl<>(this.jobDayExamineAccountDao.queryAllByLimit(jobDayExamineAccount, pageRequest), pageRequest, total);
    }

    @Override
    public List<JobDayExamineAccount> queryAll(JobDayExamineAccount jobDayExamineAccount) {
        return jobDayExamineAccountDao.queryAll(jobDayExamineAccount);
    }

    /**
     * 新增数据
     *
     * @param jobDayExamineAccount 实例对象
     * @return 实例对象
     */
    @Override
    public JobDayExamineAccount insert(JobDayExamineAccount jobDayExamineAccount) {
        this.jobDayExamineAccountDao.insert(jobDayExamineAccount);
        return jobDayExamineAccount;
    }

    /**
     * 修改数据
     *
     * @param jobDayExamineAccount 实例对象
     * @return 实例对象
     */
    @Override
    public JobDayExamineAccount update(JobDayExamineAccount jobDayExamineAccount) {
        this.jobDayExamineAccountDao.update(jobDayExamineAccount);
        return this.queryById(jobDayExamineAccount.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.jobDayExamineAccountDao.deleteById(id) > 0;
    }
}
